package com.smarthospital.dao.daoService;

import com.smarthospital.common.util.SHDateUtil;
import com.smarthospital.dao.mapper.DoctorDutyDao;
import com.smarthospital.entity.pojo.DoctorDuty;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class DoctorDutyDaoService{

    @Resource
    private DoctorDutyDao doctorDutyDao;

    public int insert(DoctorDuty pojo){
        return doctorDutyDao.insert(pojo);
    }

    public int insertSelective(DoctorDuty pojo){
        return doctorDutyDao.insertSelective(pojo);
    }

    public int insertList(List<DoctorDuty> pojos){
        return doctorDutyDao.insertList(pojos);
    }

    public int update(DoctorDuty pojo){
        return doctorDutyDao.update(pojo);
    }



    public List<DoctorDuty> queryDuties(DoctorDuty doctorDuty) {
        List<DoctorDuty> list = doctorDutyDao.queryDuties(doctorDuty);
        //过滤时间
        return list.stream().filter(d->SHDateUtil.isAfterToday(d.getDate())).collect(Collectors.toList());
    }

    public List<DoctorDuty> queryDutiesWithMajor(String major) {
        List<DoctorDuty> list = doctorDutyDao.queryDutiesWithMajor(major);
        return list.stream().filter(d->SHDateUtil.isAfterToday(d.getDate())).collect(Collectors.toList());
    }
}
